﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DemoAutofac.Models {
    public interface IEngine {
        void start();
    }
 
    public class Car {
        private IEngine engine;
        public Car(IEngine engine) {
            this.engine = engine;
        }
        public string Name { get; set; }
        public void start() {
            Console.Write("{0} ", Name);
            engine.start();
        }
    }

    public abstract class BaseEngine {
        public string Name { get; set; }
    }

    public class GasEngine : BaseEngine, IEngine {
        public GasEngine() {
            Name = "Gas Engine";
        }
        public void start() {
            Console.WriteLine("{0} combust", Name);
        }
    }

    public class ElectricEngine : BaseEngine, IEngine {
        public ElectricEngine() {
            Name = "Electric Engine";
        }
        public void start() {
            Console.WriteLine("{0} sparks", Name);
        }
    }
}
